import axios from 'axios';
const actions = {
  formGet({
    state
  }, par = {}) {
    let bones = new Promise((resolve, reject) => {
      return axios.get(
        state.API[par.API], {
          params: par.data
        }).then((res) => {
          if (res.status == 200) {
            resolve(res.data);
          } else {
            reject(res.data);
          }
      }).catch((err) => {
        reject(err);
      });
    });
    return bones;
  },
  
  post({
      state
  },par={}){
      console.log(state.API[par.API])
      let bones = new Promise((resolve, reject) => {
          return axios.post(
            state.API[par.API], par.data).then((res) => {
              if (res.status == 200) {
                resolve(res.data);
              } else {
                reject(res.data);
              }
          }).catch((err)=>{
              reject(err);
          });
      });
      return bones;
  }
}
export default {
  actions
};
